package com.xxxx.server.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xxxx.server.mapper.AppraiseMapper;
import com.xxxx.server.pojo.ErrorRecordVO;
import com.xxxx.server.pojo.RespPageBean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 错误记录
 * @author: Honors
 * @create: 2021-11-11
 */
@Service
public class ErrorRecordService {

    @Resource
    private AppraiseMapper appraiseMapper;

    /**
     * 错误信息分页
     *
     * @param currentPage
     * @param size
     * @return
     */
    public RespPageBean getPage(Integer currentPage, Integer size, String type) {
        //开启分页
        Page<ErrorRecordVO> page = new Page<>(currentPage, size);
        IPage<ErrorRecordVO> employeePage = appraiseMapper.getErrorRecord(page, type);
        // 分页记录
        List<ErrorRecordVO> records = employeePage.getRecords();
        // employeePage.getTotal() 总记录数， employeePage.getRecords() 查询出来的集合(记录)
        RespPageBean respPageBean = new RespPageBean(employeePage.getTotal(), records);
        return respPageBean;
    }
}
